import webview
import threading

from pywebview_flask import app


def start_server():
    app.run(host='127.0.0.1', port=8887)


if __name__ == '__main__':
    window = webview.create_window('test', '', hidden=True)
    try:
        app.window = window
        t = threading.Thread(target=start_server)
        t.start()
        webview.start()
    except KeyboardInterrupt:
        window.destroy()
